<?php
class Vnf_Db_Table extends Zend_Db_Table_Abstract {
   protected $_name;
   protected $_primary;

    /**
     * Get number records of table...
     *
     * @return int
     */
    public function getTotalRecords($where = null, $cond = null) {
        $select = Zend_Db_Table_Abstract::select();
        $select->from($this->_name, array('cnt' => "count('*')"));
        if ($where) {
            if (is_array($cond))
                $select->where($where, $cond);
            else $select->where($where);
        }

        $result = 0;
        $data = $this->fetchRow($select);
        @$result = $data->cnt;

        return $result;
    }

    /**
     * get records support paging...
     *
     * @return array
     */
    public function getRecords($where = null, $order = null, $count = null, $offset = 0/*, $convertToDTO = true*/)
    {
        $select = Zend_Db_Table_Abstract::select();

        if($where) {
            $select->where($where);
        }

        if($order) {
            $select->order($order);
        }

        if($count)
            $select->limit($count, $offset);
        $data = $this->fetchAll($select);

        return $data;
        /*if ($data) {
            if (isset($this->_dto)) {
                if ($convertToDTO == true)
                    return $this->_dto->populate($data);
                else
                    return $data->toArray();
            } else {
                return $data->toArray();
            }
        } else {
            return null;
        }*/
    }

}